
SET(SRC_MANTA
    app_delegate.mm
    main.mm
)

IF(${BUILD_PLATFORM} MATCHES mac)
    SET_SOURCE_FILES_PROPERTIES(${SRC_MANTA} PROPERTIES COMPILE_FLAGS "-Wno-unused-parameter -Wno-unused-private-field -Wno-format-security")
ENDIF()

INCLUDE_DIRECTORIES(${INC_MANTA} ${INC_RTMIDI})

SET(NIB_MANTA MainMenu.nib)
SET(XIB_MANTA MainMenu.xib)

ADD_EXECUTABLE(MacManta MACOSX_BUNDLE ${SRC_MANTA})

GET_TARGET_PROPERTY(FILE_MANTA MacManta LOCATION)
GET_FILENAME_COMPONENT(PATH_MANTA ${FILE_MANTA} PATH)

SET_TARGET_PROPERTIES(MacManta PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
TARGET_LINK_LIBRARIES(MacManta manta hidapi rtmidi ${LIB_SYSTEM})

ADD_DEPENDENCIES(MacManta ${XIB_MANTA})

ADD_CUSTOM_COMMAND(TARGET MacManta
                   COMMAND mkdir -p ${PATH_MANTA}/../Resources)

ADD_CUSTOM_COMMAND(TARGET MacManta
                   COMMAND ibtool
                   ARGS --errors --warnings --notices --output-format human-readable-text --compile ${PATH_MANTA}/../Resources/${NIB_MANTA} ${XIB_MANTA}
                   WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)

ADD_CUSTOM_COMMAND(TARGET MacManta
                   COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/m.png ${PATH_MANTA}/../Resources)
ADD_CUSTOM_COMMAND(TARGET MacManta
                   COMMAND iconutil -c icns -o ${PATH_MANTA}/../Resources/icon.icns ${CMAKE_CURRENT_SOURCE_DIR}/icon.iconset)
